<?php 
class staffDao extends Dao {
	
	public $table_name = 'jh_staff';
	private $fields = "id,name,annual_holiday,tone_rests,remark";
	
	public function addStaff($staff_data){
		$customer_data = $this->dao->db->build_key($staff_data, $this->fields);
		return $this->dao->db->insert($staff_data, $this->table_name);
	}
	
	
	public function operateDays($staff_id,$annual_holiday = 0,$tone_rests = 0){
		$sql = "update ".$this->table_name." set annual_holiday = annual_holiday+".$annual_holiday
		.", tone_rests = tone_rests +".$tone_rests." where id=".$staff_id."";
// 		print_r($sql);exit;
		$result = $this->dao->db->query($sql);
		if($result > 0){
			return true;
		}
		else{
			return false;
		}
	}
	
	public function getAllStaff(){
		$sql = "select ".$this->fields." from ".$this->table_name;
		//print_r($sql);exit;
		$staff_data = $this->dao->db->get_all_sql($sql);
		return $staff_data;
	}
	
	

	

	
}